package com.cn.dao.impl;

import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.dbutils.handlers.BeanHandler;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import com.cn.dao.NewsDao;
import com.cn.domain.News;
import com.cn.domain.User;
import com.cn.utils.DBUtils;

public class NewDaoImpl implements NewsDao {

	//显示新闻信息
	//按照名字查找用户名字,email,identity,tel
	/* (non-Javadoc)
	 * @see com.cn.dao.impl.NewsDao#queryAllNews()
	 */
	public List<News> queryAllNews(){
		List<News> list=new ArrayList();
		try {
			list=DBUtils.getQuryRunner().query("select * from HWUA_NEWS order by HN_ID",new BeanListHandler<News>(News.class));
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return list;
	}

	//根据新闻ID号进行阅读新闻
	@Override
	public News queryNewsById(String id) {
		News news=null;
		try {
			Object[] params={id};
			news=DBUtils.getQuryRunner().query("select * from HWUA_NEWS where HN_ID=?",new BeanHandler<News>(News.class),params);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return news;
	}
}
